<template>
  <div class="app-container">
    <el-form label-width="120px">

      <el-form-item label="姓名">
        <el-input v-model="info.name" placeholder="请输入"/>
      </el-form-item>

      <el-form-item label="性别">
        <el-select v-model="info.sex" placeholder="请选择">
          <el-option :key="0" :value="0" label="男"/>
          <el-option :key="1" :value="1" label="女"/>
          <el-option :key="-1" :value="-1" label="不限"/>
        </el-select>
      </el-form-item>

      <el-form-item label="身高">
        <el-input v-model="info.height" placeholder="请输入"/>
      </el-form-item>

      <el-form-item label="体重">
        <el-input v-model="info.weight" placeholder="请输入"/>
      </el-form-item>

      <el-form-item label="出生年月">
        <el-date-picker
          v-model="info.birth"
          type="datetime"
          placeholder="选择年月"
          value-format="yyyy-MM-dd HH:mm:ss"
          default-time="00:00:00"
        />
      </el-form-item>

      <el-form-item label="学历">
        <el-select v-model="info.education" placeholder="请选择">
          <el-option :key="0" :value="0" label="小学"/>
          <el-option :key="1" :value="1" label="初中"/>
          <el-option :key="2" :value="2" label="高中"/>
          <el-option :key="3" :value="3" label="中专"/>
          <el-option :key="4" :value="4" label="本科"/>
          <el-option :key="5" :value="5" label="大专"/>
          <el-option :key="6" :value="6" label="硕士研究生"/>
          <el-option :key="7" :value="7" label="博士研究生"/>
        </el-select>
      </el-form-item>

      <el-form-item label="毕业院校">
        <el-input v-model="info.university" placeholder="请输入"/>
      </el-form-item>

      <el-form-item label="户籍">
        <el-input v-model="info.householdRegister" placeholder="请输入"/>
      </el-form-item>

      <el-form-item label="身份证号码">
        <el-input v-model="info.idCard" placeholder="请输入"/>
      </el-form-item>

      <el-form-item label="专业">
        <el-input v-model="info.major" placeholder="请输入"/>
      </el-form-item>

      <el-form-item label="电话号码">
        <el-input v-model="info.tel" placeholder="请输入"/>
      </el-form-item>

      <el-form-item label="现住址">
        <el-input v-model="info.address" placeholder="请输入"/>
      </el-form-item>

      <el-form-item label="政治面貌">
        <el-select v-model="info.political" placeholder="请选择">
          <el-option :key="0" :value="0" label="党员"/>
          <el-option :key="1" :value="1" label="共青团员"/>
          <el-option :key="2" :value="2" label="群众"/>
        </el-select>
      </el-form-item>

      <el-form-item label="应聘岗位">
        <el-select v-model="info.job" placeholder="请选择">
          <el-option
            v-for="item in jobs"
            :key="item.id"
            :label="item.jobName"
            :value="item.id"/>
        </el-select>
      </el-form-item>

      <el-form-item label="是否同意调剂">
        <el-select v-model="info.isAgreeAdjust" placeholder="请选择">
          <el-option :key="0" :value="0" label="同意"/>
          <el-option :key="1" :value="1" label="不同意"/>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="store_baseinfo">保存</el-button>
      </el-form-item>

    </el-form>
  </div>
</template>

<script>
import base_info from '@/api/hr/base_info'
import job from '@/api/hr/job'

export default {
  data() {
    return {
      info: {},
      jobs: {},
    }
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      this.info = this.get_baseinfo()
      job.get_jobs()
        .then(response => {
          this.jobs = response.data.jobs
        })
    },
    get_baseinfo() {
      base_info.get_baseinfo()
        .then(response => {
          if (response.data.baseInfo !== null) {
            this.info = response.data.baseInfo
          } else {
            this.info = {}
          }
        })
    },
    store_baseinfo() {
      base_info.store_baseinfo(this.info)
        .then(response => {
          this.$message({
            type: 'success',
            message: '存储成功!'
          })
          this.$router.push({ path: '/dashboard' })
        })
    }
  }
}
</script>

<style scoped>

</style>
